package com.neuedu.controller.usercategory;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.neuedu.factory.ClassFactory;
import com.neuedu.service.DoctorPositionService;
import com.neuedu.service.UserCategoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

@WebServlet(name = "UserCategoryServlet", urlPatterns = "/his/category")
public class UserCategoryServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ObjectMapper om = new ObjectMapper();
        UserCategoryService dcs = (UserCategoryService) ClassFactory.createObj("UserCategoryService");
        List<Map<String, Object>> list = dcs.getAllUserCategory();
        String text = om.writeValueAsString(list);
        PrintWriter out = response.getWriter();
        out.append(text);
    }
}
